import {useMessage} from "/@/hooks/web/useMessage";
import {h} from "vue";
import {PageEnum} from "/@/enums/pageEnum";
import {useUserStoreWithOut} from "/@/store/modules/user";

export function checkLoginConfirm(fn:Function,go:Function){
    const {createConfirm}  = useMessage();
    const useStore = useUserStoreWithOut();
    if (useStore.getToken){
       return  fn()
    }else {
        createConfirm({
            iconType: 'warning',
            title: () => h('span', '登陆提示'),
            content: () => h('span', '检测到您当前未登录，请前往登录？'),
            okText: '去登陆',
            cancelText: '取消',
            onOk: async () => {
                go(PageEnum.BASE_LOGIN)
            },
        });
    }
}
